package com.zzyl.controller.manager.live;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bed")
@Api(tags = "床位管理相关接口")
public class BedController {
	
	@Autowired
	private BedService bedService;
	
	@GetMapping("/read/room/{roomId}")
	@ApiOperation(value = "根据房间id查询床位", notes = "传入房间id")
	public ResponseResult readBedByRoomId(
			@ApiParam(value = "房间ID", required = true) @PathVariable("roomId") Long roomId) {
		List<BedVo> beds = bedService.getBedsByRoomId(roomId);
		return ResponseResult.success(beds);
	}
	@PostMapping("/create")
	@ApiOperation(value = "创建床位", notes = "传入房间id")
	public ResponseResult createBed(@RequestBody BedDto bedDto) {
		bedService.saveOrUpdate(bedDto);
		return ResponseResult.success();
	}
	@GetMapping("/read/{id}")
	@ApiOperation(value = "查询所有床位", notes = "查询所有床位")
	public ResponseResult readAllBed(@PathVariable Integer id) {
		BedVo beds = bedService.readAllBed(id);
		return ResponseResult.success(beds);
	}
	@PutMapping("/update")
	@ApiOperation(value = "更新床位", notes = "传入房间id")
	public ResponseResult updateBed(@RequestBody BedVo bedVo) {
		bedService.updateBed(bedVo);
		return ResponseResult.success();
	}
	@DeleteMapping("/delete/{id}")
	@ApiOperation(value = "删除床位", notes = "传入房间id")
	public ResponseResult deleteBed(@PathVariable Integer id) {
		bedService.deleteBed(id);
		return ResponseResult.success();
	}
}
